From 3accaad34da9cee794069d20fd10b79da46ea9dd Mon Sep 17 00:00:00 2001
From: Fuwn <contact@fuwn.me>
Date: Sun, 4 Feb 2024 18:43:31 -0800
Subject: feat(badges): allow user id

---
 src/routes/user/[user]/badges/+page.svelte | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

(limited to 'src/routes/user/[user]/badges/+page.svelte')

diff --git a/src/routes/user/[user]/badges/+page.svelte b/src/routes/user/[user]/badges/+page.svelte
index 9b7b8f07..8bf2d0c3 100644
--- a/src/routes/user/[user]/badges/+page.svelte
+++ b/src/routes/user/[user]/badges/+page.svelte
@@ -50,9 +50,15 @@
 	onMount(async () => {
 		// socket.on('badges', (message) => (badges = message));
 
-		const badger = await user(data.username);
-
-		if (!badger) {
+		const isId = /^\d+$/.test(data.username);
+		const badger = isId
+			? {
+					id: parseInt(data.username),
+					name: 'User'
+			  }
+			: await user(data.username);
+
+		if (!isId && !badger) {
 			loadError = 'User not found.';
 
 			return;
-- 
cgit v1.2.3

